/*
 * @Description:
 * @Author: sheng.xia
 * @Date: 2021-12-06 19:52:16
 */
const path = require("path");
const { app, BrowserWindow, ipcMain, Notification } = require("electron");
const { stripVTControlCharacters } = require("util");
// import './main/ipcMain.ts'
function createWindow() {
  const win = new BrowserWindow({
    width: 1200,
    height: 800,
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: false, // 重启下服务 即可
    },
  });
  win.webContents.openDevTools({ mode: "right" });
  win.loadURL("http://172.16.29.236:3333/");
  //   win.loadFile(path.resolve(__dirname, "/build/index.html"));
}
app.on("window-all-closed", function () {
  if (process.platform !== "darwin") app.quit();
});
app.whenReady().then(() => {
  createWindow();
  app.on("activate", function () {
    if (BrowserWindow.getAllWindows().length === 0) createWindow();
  });
  ipcMain.on("workOut", () => {
    var notification = new Notification();
    notification.title = "工作时间结束";
    notification.show();
  });
  ipcMain.on("restOut", () => {
    var notification = new Notification();
    notification.title = "休息时间结束";
    notification.show();
  });
  ipcMain.on("longRestOut", () => {
    var notification = new Notification();
    notification.title = "长休息时间结束";
    notification.show();
  });
});
